<?php
namespace Home\Controller;
use Todo\Controller\SpaceController;

class UserController extends SpaceController {

   public function info(){
       if(IS_POST){
           $data = array(
               'nickname' =>  I('post.nickname'),
               'email' =>  I('post.email'),
               'mobile' =>  I('post.mobile')
           );
           if(!$data['nickname'] || !$data['email'] || !$data['mobile']) $this->apiError('昵称、邮箱和手机号不能为空!');
           $ret = D('Todo/Sys/User')->where(array('id'=>$this->_user['id']))->save($data);
           if($ret === false) $this->apiError();
           else $this->apiSuccess("保存成功!");
       }else{
           $info = D('Todo/Sys/User')->keyFind($this->_user['id']);
           $this->assign('data', $info);
           $this->display();
       }       
   }

    public function password(){
        $this->display();
    }
}